<template>
<view class="page-body">
	<view class="line flex">
		<text>物流公司：</text>
		<picker class="picker" mode="selector" :range="logisticsArr" range-key="name"  @change="logistChange">
			<view>{{logisticsCompany}}</view>
		</picker>
		<view class="icon xiangyou"></view>
	</view>
	<view class="line flex">
		<text>物流单号：</text>
		<input type="text" class="picker" v-model="logisticsNum" placeholder="请填写物流单号">
	</view>
	<view class="button" @click="besure">确认提交</view>
</view>
</template>

<script>
	var that;
	
	export default{
		data(){
			return {
				logisticsArr:[],
				logisticsNum:"",
				logisticsCompany:"请选择物流公司",
				expressid:"",
				rid:""
			}
		},
		onLoad(options){
			that = this;
			this.rid = options.rid;
			this.getexpressList()
		},
		methods:{
			getexpressList(){
				that.$https.POST({
					url:'/public/expressList',
					data:{
					},
					success(res){
						that.logisticsArr = res.data
					}
				})
			},
			logistChange(e){
				let index = e.detail.value;
				let logisticsArr = this.logisticsArr;
				this.logisticsCompany = logisticsArr[index].name;
				this.expressid = logisticsArr[index].number
			},
			besure(){
				if(this.logisticsCompany == "请选择物流公司"){
					this.$showToast("请选择物流公司");
					return;
				}
				if(this.logisticsNum == ""){
					this.$showToast("请填写物流单号");
					return;
				}
				that.$https.POST({
					url:'/order/returnRequestLogistics',
					data:{
						rid:that.rid,
						express:that.expressid,
						express_no:that.logisticsNum
					},
					success(res){
						that.$showToast('提交成功')
						uni.navigateBack()
					}
				})
			}
		},
		onUnload(){
			that=null;
		}
	}
	
</script>

<style lang="scss">
	page{background: #f5f5f5; padding-bottom: 105rpx;}
	.line{background: #fff;border-bottom: 1px solid #F8F8F8;line-height: 100upx;height: 100upx;font-size: 28upx;padding: 0 30upx;box-sizing: border-box;
		.picker{flex: 1;font-size: 32upx;}
		.xiangyou{font-size: 28upx;}
	}
	.button{margin-top: 70upx;}
</style>
